package demo;

/**
 * Version: 1.1
 * Author: TangJun
 * Date: 2024-07-25
 */
public class Boxes implements Runnable{

    public static int ball = 20;
    @Override
    public void run() {
        while (true) {
            if (ball <= 0) {
                System.out.println(Thread.currentThread().getName() + "拿完了！！");
                break;
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + "还剩：" + (--ball));
        }
    }
}
